package com.siterwell.push.entity;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@AllArgsConstructor
public class GS529BeanEvent {
    long alarm_status;
    long low_battery;
    long tamper;
    long fault;
    long test_alarm_status;
    long remote_alarm_status;
    long hush_status;
    long end_life;

    public GS529BeanEvent(String content) {
        if(content.length()>=12){

            String hight_str = content.substring(8,10);

            String low_str = content.substring(10,12);

            long low_data = Integer.parseInt(low_str,16);
            long high_data = Integer.parseInt(hight_str,16);

            this.alarm_status = ((0x01 & low_data) ==0?0:1);
            this.tamper = ((0x04 & low_data) ==0?0:1);

            this.low_battery = ((0x08 & low_data) ==0?0:1);
            this.fault = ((0x40 & low_data) ==0?0:1);
            this.test_alarm_status = ((0x01 & high_data) ==0?0:1);
            this.remote_alarm_status = ((0x04 & high_data) ==0?0:1);
            this.hush_status = ((0x08 & high_data) ==0?0:1);
            this.end_life = ((0x10 & high_data) ==0?0:1);
        }
    }
}
